
class SourceDataDemo:

    def __init__(self):

        # 默认的标题
        self.title = '大数据可视化展板通用模板'
        # 两个小的form看板
        self.counter = {'name': '2018年总收入情况', 'value': 88880000}
        self.counter2 = {'name': '2018年总支出情况', 'value': 66660000}
        # 总共是6个图表，数据格式用json字符串，其中第3个图表是有3个小的图表组成的
        self.echart1_data = {
            'title': '抑郁指数',
            'data': [
                {"name": "指数", "value":[543,412,362,250,235,222,223,256,308,423,563,623,685,792,876,820,750,650,700,803,823,885,850,752,652]},
            ],
            'xAxis': ["0","1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18",
           "19", "20", "21", "22", "23", "24"],

        }
        self.echart2_data = {
            'title': '世界人口总量',
            'data': [
                {"name": "巴西", "value": 182},
                {"name": "印尼", "value": 234},
                {"name": "美国", "value": 290},
                {"name": "印度", "value": 1049},
                {"name": "中国", "value": 1317},
                {"name": "世界人口", "value": 6302},
            ]
        }
        self.echart3_data = {

            'title': '时间趋势',
            'data': [
                {"name": "热度", "value": [120, 123, 225, 330, 409, 370, 289, 281, 310, 463, 611, 554]},
                {"name": "热度指数", "value": [7.0588235294117645, 7.235294117647059, 13.235294117647058, 19.41176470588235, 24.058823529411764, 21.764705882352942, 17.0, 16.529411764705884, 18.235294117647058, 27.235294117647058, 35.94117647058823, 32.588235294117645]},
            ],
            'xAxis': ["2009", "2010", "2011", "2012", "2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020"],

        }

        self.echart4_data = {
            'title': '抑郁类型',
            'data': [
                {"name": "产后抑郁", "value": 1534},
                {"name": "青少年抑郁", "value": 3708},
                {"name": "工作压力", "value": 4986},
                {"name": "老龄化抑郁", "value": 1243},
                {"name": "疫情原因", "value": 465},
            ]
        }
        self.echart5_data = {
            'title': '省份TOP',
            'data': [
                {"name": "浙江", "value": 2},
                {"name": "上海", "value": 3},
                {"name": "江苏", "value": 3},
                {"name": "广东", "value": 9},
                {"name": "北京", "value": 15},
                {"name": "深圳", "value": 18},
                {"name": "安徽", "value": 20},
                {"name": "四川", "value": 13},
            ]
        }
        # 这是一个环状图，有颜色的加上没颜色的正好等于100，半径是外圈直径和内圈直径，猜测是左闭右开
        self.echart6_data = {
            'title': '一线城市情况',
            # 'data': [
            #     {"name": "北京", "value": 78.6, "value2": 21.4, "color": "01", "radius": ['59%', '70%']},
            #     {"name": "浙江", "value": 63.4, "value2": 36.6, "color": "02", "radius": ['49%', '60%']},
            #     {"name": "福建", "value": 29.4, "value2": 70.6, "color": "03", "radius": ['39%', '50%']},
            #     {"name": "湖南", "value": 25, "value2": 75, "color": "04", "radius": ['29%', '40%']},
            #     {"name": "上海", "value": 22.5, "value2": 77.5, "color": "05", "radius": ['20%', '30%']},
            # ]
            'data': [
                {"name": "北京", "value": 87.3, "value2": 12.7, "color": "01", "radius": ['59%', '70%']},
                {"name": "浙江", "value": 79.33, "value2": 20.67, "color": "02", "radius": ['49%', '60%']},
                {"name": "福建", "value": 70.5, "value2": 29.5, "color": "03", "radius": ['39%', '50%']},
                {"name": "湖南", "value": 67.7, "value2": 32.3, "color": "04", "radius": ['29%', '40%']},
                {"name": "上海", "value": 61.5, "value2": 38.5, "color": "05", "radius": ['20%', '30%']},
            ]
        }
        # 这个在哪里用了？？？
        self.map_1_data = {
            'symbolSize': 1000,
            'data': [
                {'name': '海门', 'value': 239},
                {'name': '鄂尔多斯', 'value': 231},
                {'name': '招远', 'value': 203},
            ]
        }

    @property
    def echart1(self):
        data = self.echart1_data
        echart = {
            'title': data.get('title'),
            'names': [i.get("name") for i in data.get('data')],
            'xAxis': data.get('xAxis'),
            'data': data.get('data'),
        }
        return echart

    @property
    def echart2(self):

        data = self.echart2_data
        echart = {
            'title': data.get('title'),
            'xAxis': [i.get("name") for i in data.get('data')],
            'series': [i.get("value") for i in data.get('data')]
        }

        return echart


    @property
    def echart3(self):
        data = self.echart3_data
        echart = {
            'title': data.get('title'),
            'names': [i.get("name") for i in data.get('data')],
            'value': [i.get("value") for i in data.get('data')],
            'xAxis': data.get('xAxis'),
            'types':data.get("types")
        }
        return echart



    @property
    def echart4(self):
        data = self.echart4_data
        echart = {
            'title': data.get('title'),
            'data': data.get('data')
        }
        print(echart)
        return echart

    @property
    def echart5(self):
        data = self.echart5_data
        echart = {
            'title': data.get('title'),
            'xAxis': [i.get("name") for i in data.get('data')],
            'series': [i.get("value") for i in data.get('data')],
            'data': data.get('data'),
        }
        return echart

    @property
    def echart6(self):
        data = self.echart6_data
        echart = {
            'title': data.get('title'),
            'xAxis': [i.get("name") for i in data.get('data')],
            'data': data.get('data'),
        }
        return echart

    @property
    def map_1(self):
        data = self.map_1_data
        echart = {
            'symbolSize': data.get('symbolSize'),
            'data': data.get('data'),
        }
        return echart


class SourceData(SourceDataDemo):

    def __init__(self):
        """
        按照 SourceDataDemo 的格式覆盖数据即可
        """
        super().__init__()
        self.title = '我是新的标题'


